home *** CD-ROM | disk | FTP | other *** search
/ Network Support Library / RoseWare - Network Support Library.iso / apidev / batuti.arc / SETNIC.C < prev    next >
Text File  |  1990-01-10  |  2KB  |  59 lines

  1. /*
  2.  *
  3.  *   setnic -- sets the environment variable name in arg[1] to the Current
  4.  *   Working Directory
  5.  *   Richard Connelly,(C) 1989,1990
  6.  *
  7.  */
  8.  
  9. #include <stdio.h>
  10. #include <conio.h>
  11. #include <dos.h>
  12. #include <mem.h>
  13. #include <process.h>
  14. #include <string.h>
  15. #include "mst_env.h"
  16. #include "anw.h"
  17.  
  18.  
  19. void main(int argc, char *argv[])
  20. {
  21.  
  22. /*
  23.  *         Determine if the user is using the command correctly
  24.  */
  25.    int station;
  26.    CONNECTINFO who;
  27.  
  28.    if (argc == 1)
  29.    {
  30.       fprintf(stderr," usage:\n\t  setnic env-name  \n");
  31.       exit(-1);
  32.     }
  33.  
  34. /*
  35.  *    Determine if the user is logged into the server
  36.  */
  37.    station=GetConnectionNumber();
  38.    who=GetConnectInfo(station);
  39.    if (!strlen(who.objectname))
  40.    {
  41.       fprintf(stderr,"Setuser v1.0\n");
  42.       fprintf(stderr,"\n\n\tYou have not logged into an Advanced Netware Server.\n");
  43.       fprintf(stderr,"\tLogin to the server an execute the command again or \n");
  44.       fprintf(stderr,"\tcontact the network system administrator for assistance. \n\n");
  45.       fprintf(stderr,"\t<< Press Any Key to Continue >>");
  46.       getch();
  47.       fprintf(stderr,"\n");
  48.       exit(-1);                         /* terminate with a failure code */
  49.    }
  50.  
  51. /*
  52.  *         Set the cwd to an environment variable provided via argv
  53.  */
  54.                          /* set the environment var passed */
  55.       if (m_putenv(argv[1],strupr(GetStationAddress())))
  56.            fprintf(stderr,"Out of environment space\n");
  57.       exit(0);                          /* by argv & terminate successfully*/
  58. }
  59.